using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace SmartRename.Replacements
{
    public class StringReplacement : ReplacementBase
    {
        protected override string GetReplacement(RenameFile inputFile)
        {
            return GetReplacement(inputFile, false);
        }

        protected override string GetReplacement(RenameFile inputFile, bool toUpper)
        {
            //this functions differently from other replacements, doing the replacing inline
            //rather than passing a replacement back, so take care of the upper option here:
            string replacement = inputFile.OriginalNameWithoutExtension;
            if (this.Arguments.Count == 2)
            {
                replacement = inputFile.OriginalNameWithoutExtension.Replace(this.Arguments[0], toUpper ? this.Arguments[1].ToUpper() : this.Arguments[1]);
            }
            return replacement;
        }

        public override string EscapeKey
        {
            get { return "%string%"; }
        }

        public override string HelpText
        {
            get
            {
                return "Replaces one string with another. Usage: %string%{oldText:newText}";
            }
        }
    }
}
